Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

syntax error, unexpected token “{”, expecting variable

Description

With the last comma in the signature of the method, PHP expects another parameter after it, or the end of the signature with a closing parenthesis.

Example

<?php

class A {
    public function __construct($b,
     { }
}
?>

Alternatives

  • Add a closing parenthesis.
  • Add another parameter, then a closing parenthesis.